import Vue from 'vue'
import Router from 'vue-router'
import NotFound from '../views/404.vue'
// import NProgress from 'nprogress';
// import 'nprogress/nprogress.css';

Vue.use(Router);




let router = new Router({
  // mode: 'history',
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '*',
      component: NotFound
    },
    {
      path: '/',
      // redirect: '/three2',
      // redirect: '/three',
      redirect: '/login',
    },
    {
      path: '/login',
      component: resolve => require(['views/Login.vue'], resolve)
    },
    {
      path: '/home',
      component: resolve => require(['views/Home.vue'], resolve),
      children: [
        {
          path: '/myManage',
          component: resolve => require(['views/myManage/myView.vue'], resolve)
          // component: resolve => require(['views/myManage/myView.vue'], resolve)
        },
        {
          path: '/userManage',
          component: resolve => require(['views/systemSettings/userManage.vue'], resolve)
        },
        {
          path: '/userGroupManage',
          component: resolve => require(['views/systemSettings/userGroupManage.vue'], resolve)
        },
        {
          path: '/departmentManage', 
          component: resolve => require(['views/systemSettings/departmentManage.vue'], resolve)
        },
        {
          path: '/experimentSubject',
          component: resolve => require(['views/experimentSubjectManage/ExperimentSubject.vue'], resolve)
        },
        {
          path: '/experimentSubject/:action',
          component: resolve => require(['views/experimentSubjectManage/AddAndEditSubject.vue'], resolve)
        },
        {
          path: '/experimentSubject/action/check',
          component: resolve => require(['views/experimentSubjectManage/CheckSubject.vue'], resolve)
        },
        {
          path: '/experimentTask',
          component: resolve => require(['views/experimentTaskManage/ExperimentTask.vue'], resolve)
        },
        {
          path: '/experimentTask/:action',
          component: resolve => require(['views/experimentTaskManage/AddAndEditTask.vue'], resolve)
        },
        {
          path: '/experimentTask/action/check',
          component: resolve => require(['views/experimentTaskManage/CheckTask.vue'], resolve)
        },
        {
          path: '/statisticsOverview',
          component: resolve => require(['views/statisticsManage/OverviewManage.vue'], resolve)
        },
        {
          path: '/statisticsPersonnel',
          component: resolve => require(['views/statisticsManage/StatisticsPersonnel.vue'], resolve)
        },
        {
          path: '/statisticsPlace',
          component: resolve => require(['views/statisticsManage/StatisticsPersonnel.vue'], resolve)
        },
        {
          path: '/statisticsEquipment',
          component: resolve => require(['views/statisticsManage/StatisticsPersonnel.vue'], resolve)
        },
        {
          path: '/statisticsTestEquipment',
          component: resolve => require(['views/statisticsManage/StatisticsPersonnel.vue'], resolve)
        },
        {
          path: '/statisticsTask',
          component: resolve => require(['views/statisticsManage/StatisticsTask.vue'], resolve)
        },
        {
          path: '/statisticsSubject',
          component: resolve => require(['views/statisticsManage/StatisticsTask.vue'], resolve)
        },
        {
          path: '/experimentsPersonnel',
          component: resolve => require(['views/experimentPeopleManage/ExperimentsPeople.vue'], resolve)
        },
        {
          path: '/experimentsPersonnel/:action',
          component: resolve => require(['views/experimentPeopleManage/AddAndEditPeople.vue'], resolve)
        },
        {
          path: '/experimentsPersonnel/action/check',
          component: resolve => require(['views/experimentPeopleManage/CheckPeople.vue'], resolve)
        },
        {
          path: '/experimentsPlace',
          component: resolve => require(['views/experimentsPlaceManage/ExperimentsPlace.vue'], resolve)
        },
        {
          path: '/experimentsPlace/:action',
          component: resolve => require(['views/experimentsPlaceManage/AddAndEditPlace.vue'], resolve)
        },
        {
          path: '/experimentsPlace/action/check',
          component: resolve => require(['views/experimentsPlaceManage/CheckPlace.vue'], resolve)
        },
        {
          path: '/experimentsEquipment',
          component: resolve => require(['views/experimentsEquipmentManage/ExperimentsEquipment.vue'], resolve)
        },
        {
          path: '/experimentsEquipment/:action',
          component: resolve => require(['views/experimentsEquipmentManage/AddAndEditEquipment.vue'], resolve)
        },
        {
          path: '/experimentsEquipment/action/check',
          component: resolve => require(['views/experimentsEquipmentManage/CheckEquipment.vue'], resolve)
        },
      ]
    },
    {
      path: '/errorView',
      component: resolve => require(['views/ErrorView.vue'], resolve)
    },
  ]
});

router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});

router.afterEach(() => {
  if(document.querySelector(".M_content")) {
    document.querySelector(".M_content").scrollTop = 0;
  }
  NProgress.done();
});


export default router;
